﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.WebControls;
using CreditAgricole.Application;

namespace CreditAgricole.PageCodeBehind
{
    public class BaseViewsWebPart : WebPart
    {

        #region Properties

        protected List<VOBase> SelectedItems;

        /// <summary>
        /// Views menu
        /// </summary>
        private Menu viewsMenu;

        /// <summary>
        /// Views menu
        /// </summary>
        public Menu ViewsMenu
        {
            get { return viewsMenu; }
            set { viewsMenu = value; }
        }

        /// <summary>
        /// Web id where MEP list is installed
        /// </summary>
        public Guid WebId;

        /// <summary>
        /// Site id
        /// </summary>
        public Guid SiteId;

        #endregion

        /// <summary>
        /// Control init event
        /// </summary>
        /// <param name="e"></param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            AddViewsMenu();
        }

        /// <summary>
        /// Control Loading event
        /// </summary>
        /// <param name="e">Even related to loading control</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            SelectedItems = new List<VOBase>();
            GetDataBindToGridview();
        }


        protected virtual void AddViewsMenu()
        {
            ViewsMenu = (Menu)this.Page.LoadControl("~/_controltemplates/CreditAgricole.CustomControl/Menu.ascx");
            Panel pnlMenu = new Panel();
            pnlMenu.CssClass = "header";
            pnlMenu.Controls.Add(ViewsMenu);
            Controls.Add(pnlMenu);
        }

        /// <summary>
        /// Get data to bind with gridview and call method BindToGridView
        /// </summary>
        protected virtual void GetDataBindToGridview()
        {
            Panel pnlViewTitle = new Panel();
            pnlViewTitle.CssClass = "viewTitleclass";
        }

        /// <summary>
        /// Create a gridview, bind all data and disply it
        /// </summary>
        /// <param name="selectedItems">Data to bind in gridview</param>
        protected void BindToGridView()
        {
            Panel pnlGridview = new Panel();
            pnlGridview.CssClass = "panelView";

            DetailedGridView gridView = new DetailedGridView() { BaseObjs = SelectedItems };

            pnlGridview.Controls.Add(gridView);
            Controls.Add(pnlGridview);
        }
    }
}
